package com.study.samsung.Service;

import com.study.samsung.Dao.IndexSearchDao;
import com.study.samsung.Entity.Classification;
import com.study.samsung.Entity.Commodity;
import com.study.samsung.Entity.Succession;
import com.study.samsung.Utils.Pager;

import java.util.List;
import java.util.function.Consumer;

public class IndexSearchService {
    IndexSearchDao isd = new IndexSearchDao();

    public List<Commodity> searchTips(String searchvalue) {
        return isd.searchTips(searchvalue);
    }

    public Pager search(String searchvalue, Integer pageNo, Integer pageSize) {
        return isd.search(searchvalue,pageNo,pageSize);
    }

    public List<Classification> searchli(int xid) {
        List<Classification> classification = isd.searchli(xid);
        classification.forEach(r->{
            r.setCommodities(isd.selectligjname(r.getLname()));
        });
        return classification;
    }

    public List<Succession> selectxl() {

        List<Succession> selectxl = isd.selectxl();
        selectxl.forEach(x->{
            x.setCommodities(isd.selectgoods(x.getXid()));
        });
        return selectxl;
    }

    public List<Commodity> selectxl1(Integer xid) {
        List<Commodity> commodities = isd.selectgoods1(xid);
        return commodities;
    }

    public List<Commodity> selectnew() {
        return isd.selectnew();
    }
}
